﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GloryofKing
{
    /// <summary>
    /// 英雄
    /// </summary>
    public class Hero
    {
        private string name;   //英雄的名称
        private string role;      //英雄的角色 
        private HeroBase heroBase;   // 基础属性  
        private Skin[] skins;  // 皮肤，为了能动态的管理皮肤，单独定义
        private Skill[] skills;   // 战技

        public Hero(string heroName, string heroRole, HeroBase heroBase)
        {
            this.name = heroName;
            this.role = heroRole;
            this.heroBase = heroBase;
            this.skins = new Skin[0];   // 当英雄创建实例时，皮肤也必须初始化
            this.skills = new Skill[0];
        }
        // 英雄增加战技
        public void AddSkill(Skill skill)
        {
            Array.Resize(ref skills, skills.Length + 1);   // 把数组的大小+1
            skills[skills.Length - 1] = skill;
        }

        public void ShowSkills()
        {
            Console.Write($"{name}的战技:");
            foreach (Skill s in skills)
                Console.Write($"{s.GetName()} ");
            Console.WriteLine();
        }

        // 英雄增加皮肤
        public void AddSkin(Skin skin)
        {
            // .net 数组操作类 Array类
            // ref 指针  地址  引用传值
            Array.Resize(ref skins, skins.Length + 1);   // 把数组的大小+1
            skins[skins.Length - 1] = skin;
        }


        public string ShowSkins()
        {
            string skinNames = "" ;
            foreach (var skin in skins)
                skinNames += skin.GetName()+ " ";
            return skinNames;
        }

        public void Display()
        {
            Console.WriteLine($"英雄：{name}, 角色：{role}，皮肤：{ShowSkins()}，{heroBase.ShowHP()}，{heroBase.ShowMP()},{heroBase.Show()}");
        }
    }
}
